package fr.adfm.dto;

import java.io.Serializable;
import java.util.Collection;
import java.util.LinkedHashSet;


public class PanierDto implements Serializable{
	private static final long serialVersionUID = 1L;
	
	private Collection<ArticlePanierDto> articles = new LinkedHashSet<ArticlePanierDto>();

	
	public PanierDto() {
		super();
	}

	public PanierDto(Collection<ArticlePanierDto> articles) {
		super();
		this.articles = articles;
	}

	public Collection<ArticlePanierDto> getArticles() {
		return articles;
	}

	public void setArticles(Collection<ArticlePanierDto> articles) {
		this.articles = articles;
	}
	
	public double getPrix() {
		double prix = 0;
		for(ArticlePanierDto article : articles)
		{
			prix += article.getPrixUnitaire() * article.getQuantiteDesiree();
		}
			
		return Math.floor(prix * 100) /100;
	}

	@Override
	public String toString() {
		return "PanierDto [articles=" + articles + "]";
	}
	
	
}
